package com.fm.base.json.impl;

import com.fm.base.json.JsonBoolean;

/**
 * @author finalmachine
 */
public class BasicJsonBoolean implements JsonBoolean {
	boolean b;

	public BasicJsonBoolean(boolean b) {
		this.b = b;
	}

	@Override
	public ValueType getValueType() {
		return b ? ValueType.TRUE : ValueType.FALSE;
	}

	@Override
	public String toString() {
		return String.valueOf(b);
	}

	@Override
	public int hashCode() {
		return Boolean.hashCode(b);
	}

	@Override
	public boolean equals(final Object obj) {
		return obj instanceof JsonBoolean && ((JsonBoolean) obj).getValueType() == getValueType();
	}

    @Override
    public boolean getBoolean() {
        return b;
    }

    @Override
    public BasicJsonBoolean clone() {
        try {
            return (BasicJsonBoolean) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
    }
}
